//获取应用实例
var app = getApp();
Page({
    data: {

	    serviceFee: '',
	    platform:"iPhone",
	    isShowFootNav: false
    },
    onLoad: function () {
        var data = app.getStorageSync(app.globalData.cacheOrderPay);
        this.setData({
            "serviceFeeDesc":"(线下到付)",
            "isLocal":true,
            "serviceFee":data.serviceFee_cn,
	          "cardNbr": data.acceptNbr,
            "cardFix": data.carNbr||"",
            "typeSelectionText": data.typeSelectionText,
            "applicant": data.name,
            "contactNumber": data['address.cellNum'],
            "recipientName": data['address.contactName'],
            "area": data['address.fullAddr'],  //data.area?data.area.split('-').join('').replace(/\s+/g, "") + data.address.street:"",
            "street": data.address ? data.address.street:""  //详情
        });
	    if(app.isAndroid()){
		    this.setData({platform:"android"});
	    }
    },
    formSubmit:function (e) {
        app.loadToast();
        var param = app.getStorageSync(app.globalData.cacheOrderPay);
        param['platform'] = this.data.platform;
        param['formId'] = e.detail.formId;
        param['payType'] = 0;
        param['accountId'] = app.globalData.openId;
        var opt = {
         url: app.globalData.host+"/wx/cn/pay.ajax",
         data: param,
         sucFn:function (result) {
              param['orderId'] = result.body.orderIds[0].id;
             app.setStorageSync(app.globalData.cacheOrderPay, param);
             var obj = app.getStorageSync(app.globalData.cacheData);
             obj.num = obj.num + 1;
             obj['acceptStatus'] = "3";
             obj['acceptRemark'] = "";
             app.setStorageSync(app.globalData.cacheData, obj);
             app.setStorageSync(app.globalData.cacheRefreshTimesKey,0);
             app.redirectTo({url: '../payment/loading/loading'});
         }
        };
        app.ajax(opt);
    }
});
